package com.xwj.coupon.admin.service.event.coupontemplate;

import cn.hutool.core.bean.BeanUtil;
import com.xwj.coupon.admin.dto.resp.CouponTemplateQueryRespDTO;
import com.xwj.coupon.admin.repository.mysql.entity.CouponTemplateDO;
import com.xwj.coupon.admin.repository.redis.CouponTemplateDao;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.script.DefaultRedisScript;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @Author: XuWenjie
 * @Date: 2025-08-13
 * @Description: SyncUpdateRedisProcessor
 */
@Component
@Slf4j
public class SyncUpdateRedisProcessor {

    @Autowired
    private CouponTemplateDao couponTemplateDao;

    @EventListener
    private void syncUpdateRedis(CouponTemplateEvent event) {
        log.info("接收到事件:{},同步更新redis", event);
        CouponTemplateDO couponTemplateDO = event.getCouponTemplate();
        couponTemplateDao.setCouponTemplate(couponTemplateDO);

    }
}
